package com.buyu.mvvm.mvvm.activity;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;


import com.buyu.mvvm.mvvm.R;
import com.buyu.mvvm.mvvm.databinding.LayoutTabBinding;
import com.buyu.mvvm.mvvm.db.bean.TabInfo;
import com.buyu.mvvm.mvvm.fragment.HomeListFragment;
import com.buyu.mvvm.mvvm.fragment.MessageFragment;
import com.buyu.mvvm.mvvm.fragment.PersonalFragment;
import com.buyu.mvvm.mvvm.fragment.SponsorFragment;

import java.util.ArrayList;
import java.util.List;


public class MainActivity extends IndexFragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<Class> fragments=new ArrayList<>();
        List<View> titles=new ArrayList<>();
        List<String> tabs=new ArrayList<>();

        LayoutTabBinding homeListBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.layout_tab, null, false);
        homeListBinding.setView(new TabInfo("活动", getResources().getDrawable(R.mipmap.movable_icon)));
        fragments.add(HomeListFragment.class);
        titles.add(homeListBinding.getRoot());
        tabs.add("homeList");

        LayoutTabBinding sponsorBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.layout_tab, null, false);
        sponsorBinding.setView(new TabInfo("主办方", getResources().getDrawable(R.mipmap.sponsor_icon)));
        fragments.add(SponsorFragment.class);
        titles.add(sponsorBinding.getRoot());
        tabs.add("sponsor");

        LayoutTabBinding messageBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.layout_tab, null, false);
        messageBinding.setView(new TabInfo("消息", getResources().getDrawable(R.mipmap.message_icon)));
        fragments.add(MessageFragment.class);
        titles.add(messageBinding.getRoot());
        tabs.add("message");

        LayoutTabBinding personalBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.layout_tab, null, false);
        personalBinding.setView(new TabInfo("我的", getResources().getDrawable(R.mipmap.me_icon)));
        fragments.add(PersonalFragment.class);
        titles.add(personalBinding.getRoot());
        tabs.add("personal");

        setPageAndTitle(fragments, titles, tabs);

    }

}
